package com.nkzy.mapper;

import com.nkzy.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @Insert("INSERT INTO user(username, email) VALUES(#{username}, #{email})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertUser(User user);

    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteUserById(Long id);

    @Update("UPDATE user SET username = #{username}, email = #{email} WHERE id = #{id}")
    void updateUser(User user);

    @Select("SELECT * FROM user WHERE id = #{id}")
    User selectUserById(Long id);

    @Select("SELECT * FROM user")
    List<User> selectAllUsers();
}